package inutan.common.constant;


import inutan.common.inner.protocol.InnerPing;

/**
 * 常量
 */
public class Constant {

    public static String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCk3kWaVxO86mh5PGGhYoqoanEE0sQigyZeeHP+6ukePAaOdOpf1qAcCSXln9huo2q4E9xINDLMPA0FdpLZ50Ymu+4doOLSMUTOoxwws7sS/FgZeiXi8726KM1U9zCUzfTalSkOTj0cQsKt00NWMlw7Y69w2Xxo2hH2U8iLBRH6QQIDAQAB";
    public static String PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKTeRZpXE7zqaHk8YaFiiqhqcQTSxCKDJl54c/7q6R48Bo506l/WoBwJJeWf2G6jargT3Eg0Msw8DQV2ktnnRia77h2g4tIxRM6jHDCzuxL8WBl6JeLzvboozVT3MJTN9NqVKQ5OPRxCwq3TQ1YyXDtjr3DZfGjaEfZTyIsFEfpBAgMBAAECgYAQ+cH47lZd8VTohssWrurQBIW2lW0UkKR2vbhT2yQ9tLiIGom3bIX33QlF53uFiNYINiNMW/OPC+/bTCY6wZF7aHsY96ZX8KvzOeB91CcgcSpYQVNfXcCzMj6E8N8inaQeOT8TxVeS/8lEUmoc1YvLpqwl6BFPQ7/zIP1sHQXvQQJBAPeGGsF4ND7yNAj/7Fd/aW0vpPUTmG+opkzU92mE65r7kiovdutGIJyAmO37SDxKUdgfWR7MldmqoLMfZXxXafUCQQCqg5MU269vXiQEWF7kULubMTPjK3SB9JE+Y9WcFXL+0fwwMunsBMd44AxCDy1i2ZFv88UEnj8ofr8OqFiUo6OdAkAYYDaGUwYiJMwHDt0BiOSjAgwmrnVWma825covtA1Xx+qPCPmXFeLkRq3I0fQ9K7x/oiaup8siEnGc8jyWUC15AkBYxKKfazbLnZDWikLsTXM9ecHvc8H1naK3fjXISgpRynOli/vnmR1XOhxnj4srOOTUCW3514A9zq4cLVvgFcipAkBrICApO02hF9F1/leXXGNeyTwgezHsbi5idkknl0aqT23NTzWMdloEnMR4DMc/BJ7JWLWO058g10Pn2vra4QO9";

    public static final InnerPing PING = new InnerPing();

    public static final long SYNC_BROKER_DELAY = 5000;

    public static final String ENV_TEST = "test";

    public static final String ENV_FORMAL = "formal";


    /**
     * 合并两个参数,分别存放在 [高16 和 低16]
     * <pre>
     *     moduleId - 高16
     *     serverId - 低16
     *     例如 moduleId = 1; serverId = 1;
     *     mergeConv 的结果: 65537
     *     那么 mergeConv 对应的二进制是: [0000 0000 0000 0001] [0000 0000 0000 0001]
     * </pre>
     *
     * @param moduleId    模块ID由存放于合并结果的高16位, 该参数不得大于 32767
     * @param serverId  节点ID存放于合并结果的低16位, 该参数不得大于 65535
     * @return 合并的结果
     */
    public static int merge(int moduleId, int serverId) {
        return (moduleId << 16) + serverId;
    }

    /**
     * 得到模块ID
     * 从 cmdMerge 中获取 [高16位] 的数值
     *
     * @param cmdMerge 合并路由 cmdMerge
     * @return [高16位] 的数值
     */
    public static int getModuleId(int cmdMerge) {
        return cmdMerge >> 16;
    }

    /**
     * 得到节点ID
     * 从 cmdMerge 中获取 [低16位] 的数值
     *
     * @param cmdMerge 合并路由 cmdMerge
     * @return [低16位] 的数值
     */
    public static int getServerId(int cmdMerge) {
        return cmdMerge & 0xFFFF;
    }
}
